package org.easydev.base.webbase.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.easydev.base.webbase.bo.JsonEntity;
import org.easydev.base.webbase.exception.BizException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/api")
@RestController
@Tag(name = "Hello Rest", description = "Hello Rest")
public class HelloRest {

    @Operation(summary = "hello")
    @GetMapping("/hello")
    public String hello() {
        return "hello";
    }

    @Operation(summary = "Exception")
    @GetMapping("/exception")
    public JsonEntity<String> exception() {
        throw new RuntimeException("RuntimeException");
    }

    @Operation(summary = "BizException")
    @GetMapping("/bizException")
    public JsonEntity<String> bizException() {
        throw new BizException("error-code","bizException", HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
